
		
			

local lists = {
	{
        '物理伤害',
        '魔法伤害',
        '普攻输出',
        '技能输出',
    },
}
local data = load_excel('基础设定.xlsx','属性定义')
local is_race = {}
local max_a = #lists
local max_b = 0
for i,da in ipairs(lists) do
	for a,name in ipairs(da) do
		if data[name] and data[name].is_race then
			is_race[name] = true
		end
	end
    max_b = math.max(max_b,#da)
end

local colors = {0xff00ffff,0xffff9900,0xff00ffff,0xffff9900,0xff00ffff}
local w,h = 220,25
local x0,y0 = 10,80
local w1,h1 = 900,420
local panel = class.panel:builder {
    x = (1920-w1)/2,
    y = 250,
    w = w1,
    h = h1,
    fdf = 'tooltip_backdrop0',
    title = {
        type = 'text',
        text = '详细信息',
        font_size = 20,
        justH = "CENTER",
        justV = "MIDDLE",
        h = 80,
    },
    show_flag = false,
}
panel.items = {}
for i,da in ipairs(lists) do
    local color = colors[i]
	for a,name in ipairs(da) do
        local x,y = x0,y0 + (a-1)*h
        local text1 = panel:add_text(name..'：',x,y,w*0.65,h,12,5)
        local text2 = panel:add_text('10',x+text1.w,y,w - text1.w,h,12,5)
        text1:set_color(color)
        text2.name = name
        text2.key = data[name] and data[name].key or name
        table.insert(panel.items,text2)
    end
    x0 = x0 + w
end


function panel:update()
    local player = ac.player.self
    local hero = player.hero
    if hero then
        for _,text in ipairs(self.items) do
            local name = text.name
            local key = text.key
            local num = hero:get(key)
            local ex = ''
            if is_race[name] then
                ex = '%'
            end
            if num<10 and num>-10 and num~=0 then
                text:set_text(('%0.2f%s|n'):format(num,ex))
            else
                text:set_text(('%0.f%s|n'):format(num,ex))
            end
        end
    end
end

function panel:open()
    if self.show_flag then
        self:hide()
    else
        self:show()
    end
end


local button = class.button.create([[ui\Tab面板.tga]],320,980,64,64)
button.hotkey = 'TAB'
function button:on_button_key_down(key)
    panel:open()
end

function button:on_button_clicked()
    panel:open()
end

ac.game:notify('游戏-注册显示UI',panel,true)
